Skip to content

gh-126219: Fix crash in tkinter.Tk with non-BMP className on Tcl/Tk 8.x#151980

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:tkinter-className-nonbmp-crash
Jun 24, 2026
Merged

gh-126219: Fix crash in tkinter.Tk with non-BMP className on Tcl/Tk 8.x#151980
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:tkinter-className-nonbmp-crash

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 23, 2026

Copy link
Copy Markdown
Member

tkinter.Tk(className='\U0010FFFF') (and the underlying _tkinter.create()) crashes with a segfault when tkinter is built against Tcl/Tk 8.x.

The class name is title-cased during Tk initialization, and Tcl 8.x crashes in Tcl_UtfToTitle() on non-BMP characters (encoded as 4-byte UTF-8 sequences). Such a className is now rejected with a ValueError before Tk is initialized.

Tcl 9 supports non-BMP characters and is not affected; the check is compiled out there.

Among the other string arguments of _tkinter.create(), only className is affected — screenName, baseName and use fail gracefully.

(The same Tcl 8.x bug also affects Tcl_UtfToUpper()/Tcl_UtfToLower(), reachable via e.g. tk.call('string', 'toupper', ...), but that is a general Tcl issue that cannot be guarded on the CPython side.)

🤖 Generated with Claude Code

@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 23, 2026
@serhiy-storchaka serhiy-storchaka force-pushed the tkinter-className-nonbmp-crash branch from f5c0917 to bf0f06a Compare June 23, 2026 11:29
…l/Tk 8.x

Tcl 8.x crashes when title-casing a non-BMP character during Tk
initialization, so such a className is now rejected with a ValueError.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka force-pushed the tkinter-className-nonbmp-crash branch from bf0f06a to 8088525 Compare June 23, 2026 11:43
@serhiy-storchaka serhiy-storchaka merged commit 124c7cd into python:main Jun 24, 2026
98 of 100 checks passed
@serhiy-storchaka serhiy-storchaka deleted the tkinter-className-nonbmp-crash branch June 24, 2026 05:59
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jun 24, 2026

Copy link
Copy Markdown

GH-152045 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 24, 2026
@bedevere-app

bedevere-app Bot commented Jun 24, 2026

Copy link
Copy Markdown

GH-152046 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 24, 2026
@bedevere-app

bedevere-app Bot commented Jun 24, 2026

Copy link
Copy Markdown

GH-152047 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant